﻿# common variables
@coa_width = 768
@coa_height = 512
@canton_scale_cross_x = @[ ( 333 / coa_width ) + 0.001 ]
@canton_scale_cross_y = @[ ( 205 / coa_height ) + 0.001 ]
@canton_scale_sweden_x = @[ ( 255 / coa_width ) + 0.001 ]
@canton_scale_sweden_y = @[ ( 204 / coa_height ) + 0.001 ]
@canton_scale_norway_x = @[ ( 192 / coa_width ) + 0.001 ]
@canton_scale_norway_y = @[ ( 192 / coa_height ) + 0.001 ]
@canton_scale_denmark_x = @[ ( 220 / coa_width ) + 0.001 ]
@canton_scale_denmark_y = @[ ( 220 / coa_height ) + 0.001 ]
@third = @[1/3]

## Arabia, Anatolia, and the Iranian Plateau

ARA = { # Arabia
	flag_definition = {
		coa = ARA
		subject_canton = ARA
		priority = 1
	}
	flag_definition = {
		coa = ARA_republic
		subject_canton = ARA_republic
		priority = 10
		trigger = { 
			coa_def_republic_flag_trigger = yes
		}
	}	
	
	
	## WB originals
	
	flag_definition = {
		coa = ARA_theocracy
		subject_canton = ARA_theocracy
		priority = 10
		trigger = { 
			coa_def_theocracy_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = ARA_dictatorship
		subject_canton = ARA_dictatorship
		priority = 20
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = ARA_communist
		subject_canton = ARA_communist
		priority = 1500
		trigger = { 
			coa_def_communist_flag_trigger = yes
		}
	}
	
	# Egypt Arabia
	
	flag_definition = {
		coa = ARA_EGY
		subject_canton = ARA_EGY
		priority = 11
		
		trigger = {
			scope:actor ?= { has_variable = WB_is_Egypt_var }
		}
	}
	flag_definition = {
		coa = ARA_EGY_republic
		subject_canton = ARA_EGY_republic
		priority = 16
		trigger = {
			coa_def_republic_flag_trigger = yes
			scope:actor ?= { has_variable = WB_is_Egypt_var }
		}
	}
	
	flag_definition = {
		coa = ARA_EGY_communist
		subject_canton = ARA_EGY_communist
		priority = 1506
		coa_with_overlord_canton = EGY_subject
		trigger = { 
			coa_def_communist_flag_trigger = yes
			scope:actor ?= { has_variable = WB_is_Egypt_var }
		}
	}
	
	flag_definition = {
		coa = ARA_EGY_theocracy
		subject_canton = ARA_EGY_theocracy
		priority = 16
		trigger = {
			coa_def_theocracy_flag_trigger = yes
			scope:actor ?= { has_variable = WB_is_Egypt_var }
		}
	}
	
	flag_definition = {
		coa = ARA_EGY_dictatorship
		subject_canton = ARA_EGY_dictatorship
		priority = 26
		coa_with_overlord_canton = EGY_subject
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
			scope:actor ?= { has_variable = WB_is_Egypt_var }
		}
	}
	
	flag_definition = {
		coa = ARA_mamluk_sultanate
		subject_canton = ARA_mamluk_sultanate
		priority = 50
		trigger = {
			NOT = { has_game_rule = WB_no_extra_fluff }
			exists = scope:actor
			
			scope:actor = { has_variable = WB_is_Egypt_var }
			
			scope:actor = {
			
				has_ruling_interest_group = ig_armed_forces
				
				has_law = law_type:law_monarchy 
				has_law = law_type:law_oligarchy 
				has_law = law_type:law_serfdom
				
				OR = {
					has_law = law_type:law_slave_trade
					has_law = law_type:law_debt_slavery
				}
				
				OR = {
					NOT = { has_law = law_type:law_ethnostate }
					NOT = { has_law = law_type:law_multicultural }
				}
			}
		}
	}

	flag_definition = {
		coa = EGY_anarchist
		subject_canton = EGY_anarchist
		priority = 1507
		trigger = { 
			coa_def_anarchy_flag_trigger = yes
			scope:actor ?= { has_variable = WB_is_Egypt_var }
		}
	}
	
	# So that portrait-less tags can switch to Egypt's portraits if they move their capital to Egypt
	
	flag_definition = {
		coa = ARA_EGY
		subject_canton = ARA_EGY
		priority = 10
		
		trigger = {
			exists = c:ARA
			c:ARA = {
					OR = {
						capital = { state_region = s:STATE_LOWER_EGYPT }
						capital = { state_region = s:STATE_UPPER_EGYPT }
						capital = { state_region = s:STATE_EGYPTIAN_DESERT }
						capital = { state_region = s:STATE_MIDDLE_EGYPT }
						capital = { state_region = s:STATE_MATRUH }
						capital = { state_region = s:STATE_SINAI }
					}
			}
		}
	}
	flag_definition = {
		coa = ARA_EGY_republic
		subject_canton = ARA_EGY_republic
		priority = 15
		trigger = {
			coa_def_republic_flag_trigger = yes
			exists = c:ARA
			c:ARA = {
					OR = {
						capital = { state_region = s:STATE_LOWER_EGYPT }
						capital = { state_region = s:STATE_UPPER_EGYPT }
						capital = { state_region = s:STATE_EGYPTIAN_DESERT }
						capital = { state_region = s:STATE_MIDDLE_EGYPT }
						capital = { state_region = s:STATE_MATRUH }
						capital = { state_region = s:STATE_SINAI }
					}
			}
		}
	}
	
	flag_definition = {
		coa = ARA_EGY_communist
		subject_canton = ARA_EGY_communist
		priority = 1505
		coa_with_overlord_canton = EGY_subject
		trigger = { 
			coa_def_communist_flag_trigger = yes
			exists = c:ARA
			c:ARA = {
					OR = {
						capital = { state_region = s:STATE_LOWER_EGYPT }
						capital = { state_region = s:STATE_UPPER_EGYPT }
						capital = { state_region = s:STATE_EGYPTIAN_DESERT }
						capital = { state_region = s:STATE_MIDDLE_EGYPT }
						capital = { state_region = s:STATE_MATRUH }
						capital = { state_region = s:STATE_SINAI }
					}
			}
		}
	}
	
	flag_definition = {
		coa = ARA_EGY_theocracy
		subject_canton = ARA_EGY_theocracy
		priority = 15
		trigger = {
			coa_def_theocracy_flag_trigger = yes
			exists = c:ARA
			c:ARA = {
					OR = {
						capital = { state_region = s:STATE_LOWER_EGYPT }
						capital = { state_region = s:STATE_UPPER_EGYPT }
						capital = { state_region = s:STATE_EGYPTIAN_DESERT }
						capital = { state_region = s:STATE_MIDDLE_EGYPT }
						capital = { state_region = s:STATE_MATRUH }
						capital = { state_region = s:STATE_SINAI }
					}
			}
		}
	}
	
	flag_definition = {
		coa = ARA_EGY_dictatorship
		subject_canton = ARA_EGY_dictatorship
		priority = 25
		coa_with_overlord_canton = EGY_subject
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
			exists = c:ARA
			c:ARA = {
					OR = {
						capital = { state_region = s:STATE_LOWER_EGYPT }
						capital = { state_region = s:STATE_UPPER_EGYPT }
						capital = { state_region = s:STATE_EGYPTIAN_DESERT }
						capital = { state_region = s:STATE_MIDDLE_EGYPT }
						capital = { state_region = s:STATE_MATRUH }
						capital = { state_region = s:STATE_SINAI }
					}
			}
		}
	}
	
	flag_definition = {
		coa = EGY_anarchist
		subject_canton = EGY_anarchist
		priority = 1506
		trigger = { 
			coa_def_anarchy_flag_trigger = yes
			exists = c:ARA
			c:ARA = {
					OR = {
						capital = { state_region = s:STATE_LOWER_EGYPT }
						capital = { state_region = s:STATE_UPPER_EGYPT }
						capital = { state_region = s:STATE_EGYPTIAN_DESERT }
						capital = { state_region = s:STATE_MIDDLE_EGYPT }
						capital = { state_region = s:STATE_MATRUH }
						capital = { state_region = s:STATE_SINAI }
					}
			}
		}
	}
}

EGY = { # Egypt
		
	flag_definition = {
		coa = EGY
		subject_canton = EGY
		allow_overlord_canton = yes	
		coa_with_overlord_canton = EGY_subject			
		priority = 1
	}
	flag_definition = {
		coa = EGY_absolute_monarchy
		subject_canton = EGY_absolute_monarchy
		allow_overlord_canton = yes	
		coa_with_overlord_canton = EGY_subject			
		priority = 15
		trigger = { 
			coa_def_absolute_monarchy_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = EGY_republic
		subject_canton = EGY_republic
		priority = 10
		coa_with_overlord_canton = EGY_subject
		trigger = { 
			coa_def_republic_flag_trigger = yes
		}
	}		
	flag_definition = {
		coa = EGY_dictatorship
		subject_canton = EGY_dictatorship
		priority = 20
		coa_with_overlord_canton = EGY_subject
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = EGY_subject_GBR
		allow_overlord_canton = yes		
		priority = 50
		trigger = { 
			coa_def_british_ensign_trigger = yes
		}
	}
	
	# WB originals

	flag_definition = {
		coa = EGY_communist
		subject_canton = EGY_communist
		priority = 1500
		coa_with_overlord_canton = EGY_subject
		trigger = { 
			coa_def_communist_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = EGY_khedivate_muhd_ali
		subject_canton = EGY_khedivate_muhd_ali
		allow_overlord_canton = yes	
		coa_with_overlord_canton = EGY_subject_khedivate			
		priority = 20
		trigger = { 
			coa_def_absolute_monarchy_flag_trigger = yes
			
			exists = scope:actor
			scope:actor = { 
				NOT = { has_technology_researched = nationalism }
			}
			game_date < 1867.1.1
		}
	}
	
	flag_definition = {
		coa = EGY_khedivate_post_1867
		subject_canton = EGY_khedivate_post_1867
		allow_overlord_canton = yes	
		coa_with_overlord_canton = EGY_subject_khedivate			
		priority = 21
		trigger = { 
			coa_def_absolute_monarchy_flag_trigger = yes
			
			exists = scope:actor
			scope:actor = { 
				NOT = { has_technology_researched = nationalism }
			}
			game_date >= 1867.1.1
		}
	}
	
	flag_definition = {
		coa = EGY_subject_khedivate_GBR
		allow_overlord_canton = no		
		priority = 51
		trigger = { 
			coa_def_absolute_monarchy_flag_trigger = yes
			coa_def_british_ensign_trigger = yes
		}
	}
	
	flag_definition = {
		coa = EGY_subject_khedivate_GBR_post_1914
		allow_overlord_canton = no		
		priority = 52
		trigger = { 
			coa_def_absolute_monarchy_flag_trigger = yes
			coa_def_british_ensign_trigger = yes
			
			game_date >= 1914.1.1
		}
	}
	
	flag_definition = {
		coa = EGY_subject_khedivate_GBR_post_1923
		allow_overlord_canton = no		
		priority = 53
		trigger = {
			coa_def_absolute_monarchy_flag_trigger = no
			coa_def_monarchy_flag_trigger = yes
			coa_def_british_ensign_trigger = yes
		}
	}
	
	flag_definition = {
		coa = EGY_subject_khedivate_TUR
		allow_overlord_canton = no		
		priority = 51
		trigger = {
			coa_def_turkish_ensign_trigger = yes
		}
	}
	
	flag_definition = {
		coa = EGY_theocracy
		subject_canton = EGY_theocracy
		allow_overlord_canton = yes	
		coa_with_overlord_canton = EGY_subject
		priority = 20
		trigger = { 
			coa_def_theocracy_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = EGY_wb_mamluk_sultanate
		subject_canton = EGY_wb_mamluk_sultanate
		priority = 50
		trigger = {
			NOT = { has_game_rule = WB_no_extra_fluff }
			exists = scope:actor
			
			scope:actor = {
			
				has_ruling_interest_group = ig_armed_forces
				
				has_law = law_type:law_monarchy 
				has_law = law_type:law_oligarchy 
				has_law = law_type:law_serfdom
				
				OR = {
					has_law = law_type:law_slave_trade
					has_law = law_type:law_debt_slavery
				}
				
				OR = {
					NOT = { has_law = law_type:law_ethnostate }
					NOT = { has_law = law_type:law_multicultural }
				}
			}
		}
	}

	# WB anarchist flags
	flag_definition = {
		coa = EGY_anarchist
		subject_canton = EGY_anarchist
		priority = 1501
		trigger = { 
			coa_def_anarchy_flag_trigger = yes
		}
	}	
}

PER = { # Persia

	flag_definition = {
		coa = PER
		subject_canton = PER
		allow_overlord_canton = yes	
		coa_with_overlord_canton = PER_subject			
		priority = 1
	}
	flag_definition = {
		coa = PER_absolute_monarchy
		subject_canton = PER_absolute_monarchy
		allow_overlord_canton = yes	
		coa_with_overlord_canton = PER_subject			
		priority = 20
		trigger = { 
			coa_def_absolute_monarchy_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = PER_republic
		subject_canton = PER_republic
		priority = 10
		trigger = { 
			coa_def_republic_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = PER_dictatorship
		subject_canton = PER_dictatorship
		priority = 20
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = PER_theocracy
		subject_canton = PER_theocracy
		priority = 20
		trigger = { 
			coa_def_theocracy_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = PER_fascist
		subject_canton = PER_fascist
		priority = 1500
		trigger = { 
			coa_def_fascist_flag_trigger = yes
		}
	}
	flag_definition = {
		coa = PER_subject_GBR
		allow_overlord_canton = yes		
		priority = 50
		trigger = { 
			coa_def_british_ensign_trigger = yes
		}
	}
	
	flag_definition = {
		coa = PER_communist
		subject_canton = PER_communist
		priority = 1500
		trigger = { 
			coa_def_communist_flag_trigger = yes
		}
	}
	
	# WB anarchist flags
	flag_definition = {
		coa = PER_anarchist
		subject_canton = PER_anarchist
		priority = 1501
		trigger = { 
			coa_def_anarchy_flag_trigger = yes
		}
	}
}

TUR = { # Turkey
	flag_definition = {
		coa = TUR
		subject_canton = TUR
		allow_overlord_canton = yes		
		coa_with_overlord_canton = TUR_subject			
		priority = 1
	}	
	flag_definition = {
		coa = TUR_monarchy
		subject_canton = TUR_monarchy
		allow_overlord_canton = yes		
		coa_with_overlord_canton = TUR_subject			
		priority = 5
		trigger = { 
			coa_def_monarchy_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = TUR	
		subject_canton = TUR
		allow_overlord_canton = yes		
		coa_with_overlord_canton = TUR_subject			
		priority = 20
		trigger = { 
			coa_def_absolute_monarchy_flag_trigger = yes
		}
	}
	flag_definition = {
		coa = TUR_republic
		subject_canton = TUR_republic
		allow_overlord_canton = yes		
		coa_with_overlord_canton = TUR_republic_subject			
		priority = 35
		trigger = { 
			coa_def_republic_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = TUR_dictatorship
		subject_canton = TUR_dictatorship
		allow_overlord_canton = yes		
		coa_with_overlord_canton = TUR_republic_subject			
		priority = 40
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = TUR_theocracy
		subject_canton = TUR_theocracy
		priority = 35
		trigger = { 
			coa_def_theocracy_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = TUR_subject_GBR
		allow_overlord_canton = yes		
		priority = 50
		trigger = { 
			coa_def_british_ensign_trigger = yes
		}
	}	
	flag_definition = {
		coa = TUR_subject	
		allow_overlord_canton = yes	
		overlord_canton_offset = { 0.01 0.015 }
		overlord_canton_scale = { 0.48 0.47 }			
		priority = 50
		trigger = { 
			coa_def_french_ensign_trigger = yes
		}
	}	
	flag_definition = {
		coa = TUR_subject_GBR
		subject_canton = TUR
		allow_overlord_canton = yes			
		priority = 50
		trigger = { 
			coa_def_spanish_ensign_trigger = yes
		}
	}


	flag_definition = {
		coa = TUR_communist
		subject_canton = TUR_communist
		priority = 1500
		trigger = { 
			coa_def_communist_flag_trigger = yes
		}
	}
	
	# WB originals
	
	flag_definition = {
		coa = TUR_sick_woman	
		subject_canton = TUR_sick_woman
		allow_overlord_canton = yes		
		coa_with_overlord_canton = TUR_subject			
		priority = 30
		trigger = {
			exists = scope:actor
			OR = {
				# Gets added if...
				# You fail the Sick Man journal entries
				AND = {
					scope:actor = { has_modifier = sick_man_of_europe }
					scope:actor = { has_variable = sick_man_complete }
				}
				
				# Or start the entire chain of the Sick Man journal entries
				AND = {
					scope:actor = { has_modifier = sick_man_of_europe }
					OR = {
						scope:actor = { has_journal_entry = je_sick_man_syria }
						scope:actor = { has_journal_entry = je_sick_man_egypt }
						scope:actor = { has_journal_entry = je_sick_man_economy }
						scope:actor = { has_journal_entry = je_sick_man_education }
						scope:actor = { has_journal_entry = je_sick_man_separatism }
						scope:actor = { has_journal_entry = je_sick_man_army }
						scope:actor = { has_journal_entry = je_sick_man_bureaucracy }
					}
				}
				
				# Or is unrecognized
				AND = {
					scope:actor = {
						is_country_type = unrecognized
					}
				}
			}
		}
	}
	
	flag_definition = {
		coa = TUR_sick_woman_absolute_monarchy	
		subject_canton = TUR_sick_woman_absolute_monarchy
		allow_overlord_canton = yes		
		coa_with_overlord_canton = TUR_subject			
		priority = 35
		trigger = {
			coa_def_absolute_monarchy_flag_trigger = yes
			exists = scope:actor
			
			OR = {
				# Gets added if...
				# You fail the Sick Man journal entries
				AND = {
					scope:actor = { has_modifier = sick_man_of_europe }
					scope:actor = { has_variable = sick_man_complete }
				}
				
				# Or start the entire chain of the Sick Man journal entries
				AND = {
					scope:actor = { has_modifier = sick_man_of_europe }
					OR = {
						scope:actor = { has_journal_entry = je_sick_man_syria }
						scope:actor = { has_journal_entry = je_sick_man_egypt }
						scope:actor = { has_journal_entry = je_sick_man_economy }
						scope:actor = { has_journal_entry = je_sick_man_education }
						scope:actor = { has_journal_entry = je_sick_man_separatism }
						scope:actor = { has_journal_entry = je_sick_man_army }
						scope:actor = { has_journal_entry = je_sick_man_bureaucracy }
					}
				}
				
				# Or is unrecognized
				AND = {
					scope:actor = {
						is_country_type = unrecognized
					}
				}
			}
		}
	}

	# WB anarchist flags
	flag_definition = {
		coa = TUR_anarchist
		subject_canton = TUR_anarchist
		priority = 1501
		trigger = { 
			coa_def_anarchy_flag_trigger = yes
		}
	}	
}


## The Maghreb 

ALD = { # Algeria
	flag_definition = {
		coa = ALD
		subject_canton = ALD
		allow_overlord_canton = yes
		coa_with_overlord_canton = ALD_subject		
		priority = 1
	}
	flag_definition = {
		coa = ALD_republic
		subject_canton = ALD_republic
		priority = 34
		trigger = { 
			coa_def_republic_flag_trigger = yes
		}
	}
	flag_definition = {
		coa = ALD_subject_FRA
		priority = 30
		trigger = { 
			# WB edit
			OR= {
				coa_def_french_ensign_trigger = yes
				
				AND = {
					exists = c:FRA
					c:FRA = {
						has_diplomatic_pact = {
							who = scope:actor
							type = protectorate
							is_initiator = yes
						}
					}
				}
			}
		}
	}	
	
	flag_definition = {
		coa = ALD_deylik
		subject_canton = ALD_deylik
		priority = 30
		trigger = { 
			scope:actor ?= { has_variable = algeria_deylik_restored }
		}
	}
	flag_definition = {
		coa = ALD_barbary
		subject_canton = ALD_barbary
		priority = 30
		trigger = { 
			scope:actor ?= { has_variable = algeria_barbary_restored }
		}
	}
	flag_definition = {
		coa = CON
		subject_canton = CON
		priority = 5
		trigger = { 
			scope:actor ?= { has_variable = algeria_constantine_var }
		}
	}
	flag_definition = {
		coa = MAS
		subject_canton = MAS
		priority = 5
		trigger = { 
			scope:actor ?= { has_variable = algeria_mascara_var }
		}
	}
	flag_definition = {
		coa = AIT
		subject_canton = AIT
		priority = 5
		trigger = { 
			scope:actor ?= { has_variable = algeria_ait_abbas_var }
		}
	}
	
	# WB originals
	
	
	flag_definition = {
		coa = ALD_communist
		subject_canton = ALD_communist
		priority = 1500
		coa_with_overlord_canton = ALD_subject
		trigger = { 
			coa_def_communist_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = ALD_dictatorship
		subject_canton = ALD_dictatorship
		priority = 35
		coa_with_overlord_canton = ALD_subject
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = ALD_anarchist
		subject_canton = ALD_anarchist
		priority = 1501
		trigger = { 
			coa_def_anarchy_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = TUG
		subject_canton = TUG
		priority = 5
		trigger = { 
			scope:actor ?= { has_variable = WB_is_Touggourt_var }
		}
	}
	
	flag_definition = {
		coa = ALD_deylik_Constantine
		subject_canton = ALD_deylik_Constantine
		priority = 31
		trigger = { 
			scope:actor ?= { has_variable = algeria_deylik_restored }
			
			exists = c:MAS
		}
	}
	
	flag_definition = {
		coa = ALD_barbary_Kabylia
		subject_canton = ALD_barbary_Kabylia
		priority = 31
		trigger = { 
			scope:actor ?= { has_variable = algeria_barbary_restored }
			
			exists = c:MAS
		}
	}
	
	flag_definition = {
		coa = ALD_deylik_Constantine
		subject_canton = ALD_deylik_Constantine
		priority = 32
		trigger = { 
			scope:actor ?= { has_variable = WB_force_constantine_deylik }
		}
	}
	
	flag_definition = {
		coa = ALD_barbary_Kabylia
		subject_canton = ALD_barbary_Kabylia
		priority = 32
		trigger = { 
			scope:actor ?= { has_variable = WB_force_kabylia_barbary }
		}
	}
	
	flag_definition = {
		coa = ALD_barbary_Touggourt
		subject_canton = ALD_barbary_Touggourt
		priority = 32
		trigger = { 
			scope:actor ?= { has_variable = WB_force_touggourt_barbary }
		}
	}
	
	# Blank Algeria
	
	flag_definition = {
		coa = ALD_subject_FRA_blank
		priority = 50
		trigger = {
			OR= {
				coa_def_french_ensign_trigger = yes
				
				AND = {
					exists = c:FRA
					c:FRA = {
						has_diplomatic_pact = {
							who = scope:actor
							type = protectorate
							is_initiator = yes
						}
					}
				}
			}
			
			exists = c:MAS
			
		}
	}
	
	# Constantine Algeria
	
	flag_definition = {
		coa = ALD_CON_republic
		subject_canton = ALD_CON_republic
		priority = 40
		trigger = { 
			coa_def_republic_flag_trigger = yes
			
			scope:actor ?= {
				OR= {
					AND = {
						has_variable = algeria_constantine_var
						NOT = { has_variable = algeria_deylik_restored }
					}
				
					AND = {
						has_variable = WB_force_constantine_deylik
						has_variable = algeria_deylik_restored
					}
				
				}
			}
		}
	}
	
	flag_definition = {
		coa = ALD_CON_communist
		subject_canton = ALD_CON_communist
		priority = 1501
		coa_with_overlord_canton = ALD_subject
		trigger = { 
			coa_def_communist_flag_trigger = yes
			
			scope:actor ?= {
				OR= {
					AND = {
						has_variable = algeria_constantine_var
						NOT = { has_variable = algeria_deylik_restored }
					}
				
					AND = {
						has_variable = WB_force_constantine_deylik
						has_variable = algeria_deylik_restored
					}
				
				}
			}
		}
	}
	
	flag_definition = {
		coa = ALD_CON_dictatorship
		subject_canton = ALD_CON_dictatorship
		priority = 45
		coa_with_overlord_canton = ALD_subject
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
			
			scope:actor ?= {
				OR= {
					AND = {
						has_variable = algeria_constantine_var
						NOT = { has_variable = algeria_deylik_restored }
					}
				
					AND = {
						has_variable = WB_force_constantine_deylik
						has_variable = algeria_deylik_restored
					}
				
				}
			}
		}
	}
	
	flag_definition = {
		coa = CON_anarchist
		subject_canton = CON_anarchist
		priority = 1502
		trigger = { 
			coa_def_anarchy_flag_trigger = yes
			
			scope:actor ?= {
				OR= {
					AND = {
						has_variable = algeria_constantine_var
						NOT = { has_variable = algeria_deylik_restored }
					}
				
					AND = {
						has_variable = WB_force_constantine_deylik
						has_variable = algeria_deylik_restored
					}
				
				}
			}
		}
	}
	
	# Ait Abbas Algeria
	
	flag_definition = {
		coa = ALD_AIT_republic
		subject_canton = ALD_AIT_republic
		priority = 40
		trigger = { 
			coa_def_republic_flag_trigger = yes
			
			scope:actor ?= {
				OR= {
					AND = {
						has_variable = algeria_ait_abbas_var
						NOT = { has_variable = algeria_barbary_restored }
					}
				
					AND = {
						has_variable = WB_force_kabylia_barbary
						has_variable = algeria_barbary_restored
					}
				
				}
			}
		}
	}
	
	flag_definition = {
		coa = ALD_AIT_communist
		subject_canton = ALD_AIT_communist
		priority = 1501
		coa_with_overlord_canton = ALD_subject
		trigger = { 
			coa_def_communist_flag_trigger = yes
			
			scope:actor ?= {
				OR= {
					AND = {
						has_variable = algeria_ait_abbas_var
						NOT = { has_variable = algeria_barbary_restored }
					}
				
					AND = {
						has_variable = WB_force_kabylia_barbary
						has_variable = algeria_barbary_restored
					}
				
				}
			}
		}
	}
	
	flag_definition = {
		coa = ALD_AIT_dictatorship
		subject_canton = ALD_AIT_dictatorship
		priority = 45
		coa_with_overlord_canton = ALD_subject
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
			
			scope:actor ?= {
				OR= {
					AND = {
						has_variable = algeria_ait_abbas_var
						NOT = { has_variable = algeria_barbary_restored }
					}
				
					AND = {
						has_variable = WB_force_kabylia_barbary
						has_variable = algeria_barbary_restored
					}
				
				}
			}
		}
	}
	
	flag_definition = {
		coa = AIT_anarchist
		subject_canton = AIT_anarchist
		priority = 1502
		trigger = { 
			coa_def_anarchy_flag_trigger = yes
			
			scope:actor ?= {
				OR= {
					AND = {
						has_variable = algeria_ait_abbas_var
						NOT = { has_variable = algeria_barbary_restored }
					}
				
					AND = {
						has_variable = WB_force_kabylia_barbary
						has_variable = algeria_barbary_restored
					}
				
				}
			}
		}
	}
	
	# Touggourt Algeria
	
	flag_definition = {
		coa = ALD_TUG_republic
		subject_canton = ALD_TUG_republic
		priority = 40
		trigger = { 
			coa_def_republic_flag_trigger = yes
			
			scope:actor ?= {
				OR= {
					AND = {
						has_variable = WB_is_Touggourt_var
						NOT = { has_variable = algeria_barbary_restored }
					}
				
					AND = {
						has_variable = WB_force_touggourt_barbary
						has_variable = algeria_barbary_restored
					}
				
				}
			}
		}
	}
	
	flag_definition = {
		coa = ALD_TUG_communist
		subject_canton = ALD_TUG_communist
		priority = 1501
		coa_with_overlord_canton = ALD_subject
		trigger = {
			coa_def_communist_flag_trigger = yes
			
			scope:actor ?= {
				OR= {
					AND = {
						has_variable = WB_is_Touggourt_var
						NOT = { has_variable = algeria_barbary_restored }
					}
				
					AND = {
						has_variable = WB_force_touggourt_barbary
						has_variable = algeria_barbary_restored
					}
				
				}
			}
		}
	}
	
	flag_definition = {
		coa = ALD_TUG_dictatorship
		subject_canton = ALD_TUG_dictatorship
		priority = 45
		coa_with_overlord_canton = ALD_subject
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
			
			scope:actor ?= {
				OR= {
					AND = {
						has_variable = WB_is_Touggourt_var
						NOT = { has_variable = algeria_barbary_restored }
					}
				
					AND = {
						has_variable = WB_force_touggourt_barbary
						has_variable = algeria_barbary_restored
					}
				
				}
			}
		}
	}
	
	flag_definition = {
		coa = TUG_anarchist
		subject_canton = TUG_anarchist
		priority = 1502
		trigger = { 
			coa_def_anarchy_flag_trigger = yes
			
			scope:actor ?= {
				OR= {
					AND = {
						has_variable = WB_is_Touggourt_var
						NOT = { has_variable = algeria_barbary_restored }
					}
				
					AND = {
						has_variable = WB_force_touggourt_barbary
						has_variable = algeria_barbary_restored
					}
				
				}
			}
		}
	}
}

MAS = { # Mascara
	flag_definition = {
		coa = MAS
		subject_canton = MAS
		priority = 1
	}
	
	# WB originals
	
	flag_definition = {
		coa = MAS_dictatorship
		subject_canton = MAS_dictatorship
		priority = 30
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = MAS_communist
		subject_canton = MAS_communist
		priority = 1500
		trigger = { 
			coa_def_communist_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = ALD_anarchist
		subject_canton = ALD_anarchist
		priority = 1501
		trigger = { 
			coa_def_anarchy_flag_trigger = yes
		}
	}
}

AIT = { # Ait Abbas
	flag_definition = {
		coa = AIT
		subject_canton = AIT
		priority = 1
	}
	
	# WB originals
	
	flag_definition = {
		coa = AIT_dictatorship
		subject_canton = AIT_dictatorship
		priority = 30
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = AIT_communist
		subject_canton = AIT_communist
		priority = 1500
		trigger = { 
			coa_def_communist_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = AIT_anarchist
		subject_canton = AIT_anarchist
		priority = 1501
		trigger = { 
			coa_def_anarchy_flag_trigger = yes
		}
	}
}

CON = { # Constantine
	flag_definition = {
		coa = CON
		subject_canton = CON
		priority = 1
	}
	
	# WB originals
	
	flag_definition = {
		coa = CON_dictatorship
		subject_canton = CON_dictatorship
		priority = 30
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = CON_communist
		subject_canton = CON_communist
		priority = 1500
		trigger = { 
			coa_def_communist_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = CON_anarchist
		subject_canton = CON_anarchist
		priority = 1501
		trigger = { 
			coa_def_anarchy_flag_trigger = yes
		}
	}
}

TUG = { # Touggourt
	flag_definition = {
		coa = TUG
		subject_canton = TUG
		priority = 1
	}
	
	# WB originals
	
	flag_definition = {
		coa = TUG_republic
		subject_canton = TUG_republic
		priority = 5
		trigger = {
			coa_def_republic_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = TUG_dictatorship
		subject_canton = TUG_dictatorship
		priority = 30
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = TUG_communist
		subject_canton = TUG_communist
		priority = 1500
		trigger = { 
			coa_def_communist_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = TUG_anarchist
		subject_canton = TUG_anarchist
		priority = 1501
		trigger = { 
			coa_def_anarchy_flag_trigger = yes
		}
	}
}